package cn.shyouchi.wuguanjia.android.ui.patrol.report;

import android.content.Intent;
import android.view.View;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.List;

import cn.shyouchi.wuguanjia.android.R;

/**
 * Created by Eenie on 2016/12/28 at 13:22
 * Email: 472279981@qq.com
 * Des:
 */

public class PatrolErrorAdapter extends BaseQuickAdapter<PatrolErrorEntity.ResultMessageBean, BaseViewHolder> {
    public PatrolErrorAdapter(List<PatrolErrorEntity.ResultMessageBean> data) {
        super(R.layout.item_patrol_error_layout, data);
    }

    @Override
    protected void convert(BaseViewHolder holder, final PatrolErrorEntity.ResultMessageBean entity) {


        String time = entity.getTime();
        String date = entity.getTime();

        try {
            date = time.substring(0, 10);
            time = time.substring(11, time.length());
        } catch (Exception e) {
            e.printStackTrace();
        }

        holder.setText(R.id.tv_patrol_person_name, String.format("上报单号：%1s", entity.getUniqueid()));
        holder.setText(R.id.tv_patrol_time, time);
        holder.setText(R.id.tv_patrol_submit_time, date);
        holder.setText(R.id.tv_patrol_state, "异常");
        holder.setText(R.id.tv_patrol_addr, entity.getInspectionpoint().getInspectionname());

        holder.itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(mContext, PreviewPatrolErrorDetailActivity.class);
                intent.putExtra("info", entity);
                mContext.startActivity(intent);
            }
        });
    }
}
